//
//  YKTabBarViewController.m
//  baisi
//
//  Created by 吴高烽 on 16/8/28.
//  Copyright © 2016年 吴高烽. All rights reserved.
//

#import "YKTabBarViewController.h"
#import "YKEssenceViewController.h"
#import "YKMeViewController.h"
#import "YKCommonsViewController.h"
#import "YKNewViewController.h"
#import "YKTabBar.h"
#import "YKNavigationController.h"
@interface YKTabBarViewController ()

@end

@implementation YKTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    /*
     // 添加子控制器
     UIViewController *vc01 = [[UIViewController alloc] init];
     vc01.tabBarItem.title = @"精华";
     vc01.tabBarItem.image = [UIImage imageNamed:@"tabBar_essence_icon"];
     vc01.tabBarItem.selectedImage = [UIImage imageNamed:@"tabBar_essence_click_icon"];
     
     NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
     attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
     attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
     [vc01.tabBarItem setTitleTextAttributes:attrs forState:UIControlStateNormal];
     
     NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
     selectedAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
     selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
     [vc01.tabBarItem setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
     
     */
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
    selectedAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    
    UITabBarItem *item = [UITabBarItem appearance];

    
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
    
    [self setupChildrenViewControllerWith:[[YKEssenceViewController alloc]init] Image:@"tabBar_essence_icon" SelectedImage:@"tabBar_essence_click_icon" attrs:attrs SelectedAttrs:selectedAttrs Title:@"精华"];
    
    [self setupChildrenViewControllerWith:[[YKNewViewController alloc]init] Image:@"tabBar_new_icon" SelectedImage:@"tabBar_new_click_icon" attrs:attrs SelectedAttrs:selectedAttrs Title:@"最新"];
    
    [self setupChildrenViewControllerWith:[[YKCommonsViewController alloc]init] Image:@"tabBar_friendTrends_icon" SelectedImage:@"tabBar_friendTrends_click_icon" attrs:attrs SelectedAttrs:selectedAttrs Title:@"关注"];

    [self setupChildrenViewControllerWith:[[YKMeViewController alloc]initWithStyle:UITableViewStyleGrouped] Image:@"tabBar_me_icon" SelectedImage:@"tabBar_me_click_icon" attrs:attrs SelectedAttrs:selectedAttrs Title:@"我"];
    
    [self setValue:[[YKTabBar alloc]init] forKey:@"tabBar"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)setupChildrenViewControllerWith:(UIViewController *)vc1 Image:(NSString*)image SelectedImage:(NSString*)selectedImage attrs:(NSMutableDictionary*)attrs SelectedAttrs:(NSMutableDictionary*)seleAttrs Title:(NSString*)title{
//    vc1.view.backgroundColor = YKRandomColor ;
    vc1.tabBarItem.title = title;
    vc1.tabBarItem.image = [UIImage imageNamed:image] ;
    vc1.tabBarItem.selectedImage = [[UIImage imageNamed: selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    YKNavigationController *nav = [[YKNavigationController alloc]initWithRootViewController:vc1];
//    [[UINavigationBar appearance]setBackgroundImage:[UIImage imageNamed:@"navigationbarBackgroundWhite"] forBarMetrics:UIBarMetricsDefault];
//    [vc1.tabBarItem setTitleTextAttributes:attrs forState:UIControlStateNormal];
//    [vc1.tabBarItem setTitleTextAttributes:seleAttrs forState:UIControlStateSelected];
    [self addChildViewController:nav];

}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
